<template>
  <div>
    <el-popover placement="top-start" width="256" trigger="click">
      <div>
        <img src="@/assets/img/menu/logoBig.jpg">
      </div>
      <div class="f18 b white" slot="reference" id="sitename">新疆大学</div>
    </el-popover>
    <el-menu
      id="menu"
      router
      :default-active="this.$route.path"
      background-color="#2f353f"
      text-color="#d9d9d9"
      active-text-color="white"
      :collapse-transition="false"
      :unique-opened="true"
      :collapse="this.$store.state.isCollapse"
      v-if="this.$store.state.identity === '门户维护人员'"
    >
      <!-- <el-menu-item index="/admin/index">
        <i class="el-icon-s-home"></i>
        <span slot="title">资料</span>
      </el-menu-item> -->
      <el-submenu index="">
        <template slot="title">
          <i class="el-icon-document"></i>
          <span>学习资源管理</span>
        </template>
        <el-menu-item index="/docmangement/add" ><i class="el-icon-document"></i>上传资源</el-menu-item>
        <el-menu-item index="/docmangement/mangement" ><i class="el-icon-document"></i>管理资源</el-menu-item>
      </el-submenu>
      
      <el-submenu index="exam">
        <template slot="title">
          <i class="el-icon-user-solid"></i>
          <span>考试管理</span>
        </template>
        <el-menu-item index="/exam/index">
        <i class="el-icon-s-home"></i>
        <span slot="title">考试添加</span>
      </el-menu-item>
        <el-menu-item index="/exam/manage">
        <i class="el-icon-s-home"></i>
        <span slot="title">试卷</span>
      </el-menu-item>
        <el-menu-item index="/exam/paper/index">
          <i class="el-icon-s-home"></i>
          <span slot="title">试题录入</span>
        </el-menu-item>
      </el-submenu>
      <!-- <el-menu-item index="/paper/index">
        <i class="el-icon-s-home"></i>
        <span slot="title">添加试卷</span>
      </el-menu-item> -->
      <el-submenu index="member">
        <template slot="title">
          <i class="el-icon-user-solid"></i>
          <span>人员信息管理</span>
        </template>
        <el-menu-item index="/member/add">
          <i class="el-icon-s-home"></i>
          <span slot="title">添加人员</span>
        </el-menu-item>
        <el-menu-item index="/member/index">
          <i class="el-icon-s-home"></i>
          <span slot="title">人员信息</span>
        </el-menu-item>
      </el-submenu>
       <el-menu-item index="/teacher/index">
        <i class="el-icon-s-home"></i>
        <span slot="title">教师考试信息</span>
      </el-menu-item>
       <el-menu-item index="/modify/description">
        <i class="el-icon-s-home"></i>
        <span slot="title">修改操作说明</span>
      </el-menu-item>
       <el-menu-item index="/commitment/edit">
        <i class="el-icon-s-home"></i>
        <span slot="title">修改承诺书</span>
      </el-menu-item>
       <el-menu-item index="/notice/add">
        <i class="el-icon-s-home"></i>
        <span slot="title">添加通知</span>
      </el-menu-item>

      <el-submenu index="admin">
        <template slot="title">
          <i class="el-icon-user-solid"></i>
          <span>用户设置</span>
        </template>
        <el-menu-item @click="changePassword()">修改密码</el-menu-item>
        <el-menu-item @click="logout()">注销退出</el-menu-item>
        <el-menu-item index="/admin/index">
        <!-- <i class="el-icon-s-home"></i> -->
        <span slot="title">用户资料</span>
      </el-menu-item>
      </el-submenu>
    </el-menu>
    <el-menu
      id="menu"
      router
      :default-active="this.$route.path"
      background-color="#2f353f"
      text-color="#d9d9d9"
      active-text-color="white"
      :collapse-transition="false"
      :unique-opened="true"
      :collapse="this.$store.state.isCollapse"
      v-else-if="this.$store.state.identity === '教务处'"
    >
      <el-menu-item index="/admin/index">
        <i class="el-icon-s-home"></i>
        <span slot="title">资料</span>
      </el-menu-item>

      <el-menu-item index="/teacher/index">
        <i class="el-icon-s-home"></i>
        <span slot="title">教师信息</span>
      </el-menu-item>

      <el-menu-item index="/view/view">
        <i class="el-icon-s-home"></i>
        <span slot="title">查看监考资格</span>
      </el-menu-item>

      <el-submenu index="admin">
        <template slot="title">
          <i class="el-icon-user-solid"></i>
          <span>用户设置</span>
        </template>
        <el-menu-item @click="changePassword()">修改密码</el-menu-item>
        <el-menu-item @click="logout()">注销退出</el-menu-item>
      </el-submenu>
    </el-menu>
    <el-menu
      id="menu"
      router
      :default-active="this.$route.path"
      background-color="#2f353f"
      text-color="#d9d9d9"
      active-text-color="white"
      :collapse-transition="false"
      :unique-opened="true"
      :collapse="this.$store.state.isCollapse"
      v-else-if="this.$store.state.identity === '考试中心'"
    >
      <el-menu-item index="/admin/index">
        <i class="el-icon-s-home"></i>
        <span slot="title">资料</span>
      </el-menu-item>

      <el-menu-item index="/teacher/index">
        <i class="el-icon-s-home"></i>
        <span slot="title">教师信息</span>
      </el-menu-item>

      <el-menu-item index="/check/check">
        <i class="el-icon-s-home"></i>
        <span slot="title">审核监考资格</span>
      </el-menu-item>

      <el-submenu index="admin">
        <template slot="title">
          <i class="el-icon-user-solid"></i>
          <span>用户设置</span>
        </template>
        <el-menu-item @click="changePassword()">修改密码</el-menu-item>
        <el-menu-item @click="logout()">注销退出</el-menu-item>
      </el-submenu>
    </el-menu>
    <el-menu
      id="menu"
      router
      :default-active="this.$route.path"
      background-color="#2f353f"
      text-color="#d9d9d9"
      active-text-color="white"
      :collapse-transition="false"
      :unique-opened="true"
      :collapse="this.$store.state.isCollapse"
      v-else=""
    >
      <el-menu-item index="/admin/index">
        <i class="el-icon-s-home"></i>
        <span slot="title">资料</span>
      </el-menu-item>

      <el-menu-item index="/teacher/index">
        <i class="el-icon-s-home"></i>
        <span slot="title">报名监考</span>
      </el-menu-item>

      <el-menu-item index="/teacher/state">
        <i class="el-icon-s-home"></i>
        <span slot="title">报名状态</span>
      </el-menu-item>
      <el-menu-item index="/teacher/process">
        <i class="el-icon-s-home"></i>
        <span slot="title">学习进度</span>
      </el-menu-item>
      <el-menu-item index="/check/test">
        <i class="el-icon-s-home"></i>
        <span slot="title">查看考场分布</span>
      </el-menu-item>
      <el-menu-item index="/check/status">
        <i class="el-icon-s-home"></i>
        <span slot="title">操作说明</span>
      </el-menu-item>
      <el-submenu index="admin">
        <template slot="title">
          <i class="el-icon-user-solid"></i>
          <span>用户设置</span>
        </template>
        <el-menu-item @click="changePassword()">修改密码</el-menu-item>
        <el-menu-item @click="logout()">注销退出</el-menu-item>
      </el-submenu>
    </el-menu>
    <admin-edit dialog-form-title="修改密码" ref="adminEdit"></admin-edit>
  </div>
</template>

<script>
import Message from '@/plugins/message'
import AdminEdit from '@/views/admin/edit.vue'
export default {
  name: 'tf-menu',
  components: {
    AdminEdit
  },
  data () {
    return {
      dialogFormVisible: false,
      dialogId: this.$store.state.userid,
      dialogEditTime: 0
    }
  },
  methods: {
    logout: function () {
      this.$store.dispatch('logout')
      Message.success('注销成功')
      this.$router.replace('/login')
    },
    changePassword: function () {
      this.toggleDialog(true)
    },
    toggleDialog: function (flag) {
      flag && (this.dialogEditTime = new Date().getTime())
      this.$refs.adminEdit.toggleDialog(flag)
    },
    checkMenu: function (index) {
      return this.$store.state.userid === 1 || this.$store.state.rules.includes(`Menu${index.replace(/\//g, '-')}`)
    },
    loadMine () {
      // empty for change password call
    }
  }
}
</script>

<style scoped>
.el-menu {
  border: 0;
  display: block;
  overflow: hidden;
}
.el-menu-item.is-active {
  background-color: #272c35 !important;
}
#sitename {
  margin: 0 auto;
  width: 120px;
  height: 60px;
  line-height: 60px;
  text-align: center;
  border-bottom: 1px solid #2b313a;
  background: url(../../assets/img/menu/logo.png) no-repeat left;
  cursor: pointer;
}
</style>
